package com.hu.bgp.server;

import java.io.File;

/**
 * Een gametype wordt aangemaakt door de BarLoader en bevat alle informatie over
 * lopende games en hoe een nieuwe game te starten.
 * 
 * @author ejvos
 */
public class GameType
{
	private GameServerContext gsc;
	private File barArchive;
	private File barExtractDir;
	private Class<?> serverClass;
	private String alias;
	private String displayName;
	private String description;
	private boolean isActive = false;
	private GameInstanceCollection gameInstances = new GameInstanceCollection();

	public GameType(GameServerContext gsc, File barArchive, File barExtractDir, Class<?> serverClass, String alias, String displayName, String description)
	{
		this.gsc = gsc;
		this.barArchive = barArchive;
		this.barExtractDir = barExtractDir;
		this.serverClass = serverClass;
		this.alias = alias;
		this.displayName = displayName;
		this.description = description;
	}

	public File getBarArchive()
	{
		return barArchive;
	}

	public File getBarExtractDir()
	{
		return barExtractDir;
	}

	public Class<?> getServerClass()
	{
		return serverClass;
	}

	public String getAlias()
	{
		return alias;
	}

	public String getDisplayName()
	{
		return displayName;
	}

	public String getDescription()
	{
		return description;
	}

	public boolean isActive()
	{
		return isActive;
	}

	public void activate()
	{
		isActive = true;
	}

	public void deactivate()
	{
		// TODO
		// kill all instances
		// release resources
		// release classloaders
		isActive = false;
		System.gc();
	}

	public GameInstanceCollection getGameInstances()
	{
		return gameInstances;
	}
}
